package com.java.comprehensive.arithmetic.leecode.easy;

/**
 * @Author: Dgg
 * @Date: 2022/1/9 21:33
 * <p>
 * 移动零
 */
public class LeetCode_283 {
	public static void moveZeroes(int[] nums) {
		int l = 0;
		int r = l + 1;

		while (l < r && r < nums.length) {
			if (nums[l] == 0) {
				if (nums[r] != 0) {
					int temp = nums[l];
					nums[l] = nums[r];
					nums[r] = temp;
					l++;
				}
				r++;
			} else {
				r++;
				l++;
			}
		}


	}

	public static void main(String[] args) {
		int[] nums = {6, 0, 1, 0};
		moveZeroes(nums);
		System.out.println();
	}

}
